home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / buildHypergraphNodePopupMenu < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.2 KB  |  279 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 2000 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. //
  34. //  Alias|Wavefront Script File
  35. //  MODIFY THIS AT YOUR OWN RISK
  36. //
  37. //  Creation Date:  Date
  38. //  Author:         jdc rendering
  39. //
  40. // Description:
  41. //
  42. //        description
  43. //                                                
  44.  
  45. source clipMenuCommands.mel;
  46.  
  47. //---------------------------------------------------------------------------
  48. // The procedure which builds the menu
  49. //
  50. global proc buildHypergraphNodePopupMenuItems(
  51.     string $hypershade,
  52.     string $node)
  53. {
  54.     //
  55.     // Description:
  56.     //    This procedure is called when the user RMB clicks on a node in a scene 
  57.     //    or graph tab hypershade editor.
  58.     //    This procedure builds the menu items which will appear in the popup
  59.     //    menu.
  60.     //    The popup menu this procedure generates can vary depending on the 
  61.     //    type of the node under the cursor.
  62.     //
  63.  
  64.     string $nodeType = `nodeType $node`;
  65.  
  66.     if ($nodeType == "place3dTexture")
  67.     {
  68.         menuItem 
  69.             -label "Fit to Group Bounding Box" 
  70.             -command ("source AEplace3dTextureTemplate.mel; " +
  71.                       "PSfitPlacementToGroup " + $node);
  72.  
  73.         string $selection[] = `ls -sl`;
  74.  
  75.         if (size($selection) > 0)
  76.         {
  77.             string $leadSelectionItem = $selection[0];
  78.             menuItem 
  79.                 -label 
  80.                     ("Parent Placement to Selection ("
  81.                         + $leadSelectionItem
  82.                         + ")")
  83.                 -command ("parent " + $node + " " + $leadSelectionItem);
  84.         }
  85.         else
  86.         {
  87.             menuItem 
  88.                 -label "Parent Placement to Selection"
  89.                 -enable false;
  90.         }
  91.     }
  92.     else if (isClassified($node, "shader"))
  93.     {
  94.         string $shadingGroupArray[] = 
  95.             `listConnections 
  96.                 -source false 
  97.                 -destination true 
  98.                 -type "shadingEngine" 
  99.                 $node`;
  100.         int $isOceanShader = nodeType( $node ) == "oceanShader";
  101.         int $groupSize = size($shadingGroupArray);
  102.         if( $groupSize == 2 && $isOceanShader){
  103.             // OceanShaders are assigned twice to the same group:
  104.             // once for displacement and once for surfaceShading.
  105.             // Thus we get two identical groups, while we wish to display
  106.             // just one.
  107.             if( $shadingGroupArray[0] == $shadingGroupArray[1] ){
  108.                 $groupSize = 1; // force use of "assign material"
  109.             }
  110.         }
  111.  
  112.         if ( $groupSize <= 1)
  113.         {
  114.             if( $isOceanShader )
  115.             {
  116.                 menuItem 
  117.                     -label "Assign Material To Selection" 
  118.                     -command ("assignOceanShader " + $node);
  119.             } 
  120.             else 
  121.             {
  122.                 menuItem 
  123.                     -label "Assign Material To Selection" 
  124.                     -command ("hyperShade -assign " + $node);
  125.             }
  126.             menuItem -divider true;    
  127.             menuItem 
  128.                 -label "Select Objects With Material" 
  129.                 -command ("hyperShade -objects " + $node);
  130.             menuItem 
  131.                 -label "Frame Objects With Material" 
  132.                 -command 
  133.                     ("hyperShade -objects " 
  134.                         + $node 
  135.                         + ";fitAllPanels -selected");
  136.         }
  137.         else
  138.         {
  139.             int $i;
  140.  
  141.             for ($i = 0; $i < size($shadingGroupArray); $i++)
  142.             {
  143.                 menuItem 
  144.                     -label ("Assign "+ $shadingGroupArray[$i] +" To Selection") 
  145.                     -command ("hyperShade -assign " + $shadingGroupArray[$i]);
  146.             }
  147.             menuItem -divider true;    
  148.  
  149.             for ($i = 0; $i < size($shadingGroupArray); $i++)
  150.             {
  151.                 menuItem 
  152.                     -label ("Select Objects in " + $shadingGroupArray[$i]) 
  153.                     -command ("hyperShade -objects " + $shadingGroupArray[$i]);
  154.                 menuItem 
  155.                     -label ("Frame Objects in " + $shadingGroupArray[$i]) 
  156.                     -command 
  157.                         ("hyperShade -objects " 
  158.                             + $shadingGroupArray[$i] 
  159.                             + ";fitAllPanels -selected");
  160.             }
  161.         }
  162.         menuItem -divider true;
  163.     }
  164.     else if (isClassified($node, "texture"))
  165.     {
  166.         menuItem 
  167.             -label "Assign Texture's Material to Selection" 
  168.             -command 
  169.                 ("hypergraphAssignTextureToSelection  " + $node);
  170.  
  171.         if ($nodeType == "file")
  172.         {
  173.             menuItem 
  174.                 -label "Reload Image File" 
  175.                 -command 
  176.                     ("string $name=`getAttr "
  177.                         + $node 
  178.                         + ".fileTextureName`;"
  179.                         + "setAttr " 
  180.                         + $node 
  181.                         + ".fileTextureName "
  182.                         + "-type \"string\" $name;");
  183.         }
  184.         menuItem -divider true;
  185.     }
  186.     else if (isClassified($node, "light")) 
  187.     {
  188.         menuItem
  189.             -label "Make Links with Selected Objects"
  190.             -command ("lightlink -make -light "+$node+" -useActiveObjects");
  191.  
  192.         menuItem
  193.             -label "Break Links with Selected Objects"
  194.             -command ("lightlink -break -light "+$node+" -useActiveObjects");
  195.  
  196.         menuItem -divider true;
  197.  
  198.         menuItem
  199.             -label "Select Objects Illuminated by Light"
  200.             -command ("selectObjectsIlluminatedBy "+$node);
  201.  
  202.         menuItem
  203.             -label "Frame Objects Illuminated by Light"
  204.             -command ("selectObjectsIlluminatedBy "+$node+"; fitAllPanels -selected");
  205.  
  206.         menuItem -divider true;
  207.     }
  208.     else if ($nodeType == "textureBakeSet" || $nodeType == "vertexBakeSet" )
  209.     {
  210.         menuItem 
  211.             -label "Assign Selection To Bake Set" 
  212.             -command ("sets -forceElement " + $node + " `ls -dag -objectsOnly -geometry -selection`" );
  213.         menuItem -divider true;    
  214.         menuItem 
  215.             -label "Select Objects In Bake Set" 
  216.             -command ("select " + $node);
  217.         menuItem 
  218.             -label "Frame Objects In Bake Set" 
  219.             -command 
  220.                 ("select " + $node + " ;fitAllPanels -selected");
  221.  
  222.         menuItem -divider true;
  223.     }
  224.     else if ($nodeType == "animClip")
  225.     {
  226.         menuItem 
  227.             -label "Copy" 
  228.             -annotation "Copy Clip (to be pasted in TraX Window)" 
  229.             -command ("clipCopyMenuCommand " + $node) 
  230.             ClipCopyItem;
  231.         menuItem 
  232.             -label "Instance" 
  233.             -annotation "Instance Clip at Current Time" 
  234.             -command ("clipInstanceMenuCommand " + $node) 
  235.             ClipInstanceItem;
  236.         menuItem 
  237.             -label "Duplicate"  
  238.             -annotation "Duplicate Clip" 
  239.             -command ("clipDuplicateMenuCommand " + $node) 
  240.             ClipDuplicateItem;
  241.         menuItem 
  242.             -label "Export"  
  243.             -annotation "Export Clip" 
  244.             -command ("doExportClipArgList 2 { \"\", \"" + $node + "\"}") 
  245.             ClipExportItem;
  246.         menuItem -divider true;
  247.         menuItem 
  248.             -label "Apply Pose" 
  249.             -annotation "Move Character to Saved Pose or Clip Start" 
  250.             -command ("clipApplyPoseMenuCommand " + $node)
  251.             ClipApplyPoseItem;
  252.         menuItem -divider true;
  253.     }
  254.  
  255.     menuItem
  256.         -label "Select Input Nodes"
  257.         -command ("select -noExpand `listHistory " + $node + "`")
  258.         -annotation "Select all nodes input to this node";
  259.     menuItem
  260.         -label "Select Output Nodes"
  261.         -command 
  262.             ("select -noExpand `listHistory -future true " 
  263.                 + $node 
  264.                 + "`")
  265.         -annotation "Select all nodes output from this node";
  266.  
  267.     menuItem -divider true;
  268.  
  269.     menuItem 
  270.         -label "Attribute Editor..."
  271.         -command 
  272.             ("hyperGraph -e -attributeEditor single -useFeedbackList " 
  273.                 + $hypershade);
  274.     menuItem 
  275.         -label "Rename"
  276.         -command 
  277.             ("hyperGraph -e -rename -useFeedbackList " + $hypershade);
  278. }
  279.